﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json.Serialization;

namespace Xc.DataAccess.OneNetCore.Services
{
    public class UpdateDevcieRequest : RequestCore<UpdateDevcieResponse>
    {
        protected internal override string RequestPath => $"devices/{DeviceId}";
        protected internal override bool SendBody => true;
        protected internal override HttpMethod HttpMethod => HttpMethod.Put;
        /// <summary>
        /// 设备编号
        /// </summary>
        [JsonIgnore]
        public string DeviceId { get; set; }
        /// <summary>
        /// 设备名称
        /// </summary>
        [JsonPropertyName("title")]
        public string? Title { get; set; }
        /// <summary>
        /// 设备描述
        /// </summary>
        [JsonPropertyName("desc")]
        public string? Description { get; set; }
        /// <summary>
        /// 设备标签，字符串数组
        /// </summary>
        [JsonPropertyName("tags")]
        public string[]? Tags { get; set; }
        /// <summary>
        /// 坐标信息
        /// </summary>
        [JsonPropertyName("location")]
        public Location? Location { get; set; }
        /// <summary>
        /// 是否私有字段
        /// </summary>
        [JsonPropertyName("private")]
        public bool? IsPrivate { get; set; }
        /// <summary>
        /// 其他信息
        /// </summary>
        [JsonPropertyName("other")]
        public Dictionary<string, string>? Other { get; set; } = new Dictionary<string, string>();
        /// <summary>
        /// IMSI码
        /// </summary>
        string iMEI;
        /// <summary>
        /// IMSI码
        /// </summary>
        [JsonIgnore]
        public string IMEI
        {
            get => iMEI; set
            {
                if (iMEI == value)
                {
                    return;
                }

                iMEI = value;
                AuthInfo[IMEI] = IMSI;
            }
        }
        string iMSI;
        /// <summary>
        /// IMSI码
        /// </summary>
        [JsonIgnore]
        public string IMSI
        {
            get => iMSI; set
            {
                if (iMSI == value)
                {
                    return;
                }
                iMSI = value;
                AuthInfo[IMEI] = IMSI;
            }
        }
        /// <summary>
        /// 认证信息
        /// </summary>
        [JsonPropertyName("auth_info")]
        public Dictionary<string, string> AuthInfo { get; set; } = new Dictionary<string, string>();
    }
}
